<template>
  <slot>{{ list[0] }}</slot>
  <a-popover :position="position">
    <div class="auth-nums" v-if="list.length > 1">+{{ list.length - 1 }}</div>
    <template #content>
      <a-scrollbar :style="{ 'max-height': '200px', overflow: 'auto', 'max-width': maxWidth }">
        <div class="pop-orgs">
          <div v-for="(item, index) of list" :key="index">
            <slot name="content-item" :item="item">{{ item }}</slot>
          </div>
        </div>
      </a-scrollbar>
    </template>
  </a-popover>
</template>
<script setup>
  defineProps({
    maxWidth: {
      type: String,
      default: 'auto',
    },
    list: {
      type: Array,
      default: () => [],
    },
    position: {
      type: String,
      default: 'top',
    },
  })
</script>
<style lang="less" scoped>
  .auth-nums {
    display: inline-block;
    background-color: #1890ff;
    border-radius: 10px;
    padding: 0 7px;
    color: #fff;
    margin-left: 3px;
  }
  .pop-orgs {
    max-width: 760px;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    div {
      background: #f2f3f5;
      margin-right: 10px;
      margin-bottom: 10px;
      padding: 2px 6px;
      border-radius: 2px;
      color: #1d2129;
      word-break: break-all;
    }
  }
</style>
